Fund = new Object();

// custom Vtype for vtype:'Rate'
Ext.apply(Ext.form.field.VTypes, {
	Rate : function(v) {
		return /^100(\.0{0,2})? *%?$|^\d{1,2}(\.\d{1,2})? *%?$/.test(v);
	},
	RateText : 'Invalid Rate',
	RateMask : /[\d\.%]/i
});

Fund.getSearchBar = function() {

	var fundStore = new Ext.data.Store({
		fields : [ {
			name : 'id',
			type : 'int'
		}, {
			name : 'fundName',
			type : 'string'
		}, {
			name : 'fundCode',
			type : 'string'
		}, {
			name : 'status',
			type : 'string'
		} ]
	});

	return Ext.create('Ext.form.FieldContainer', {

		items : [ {
			xtype : 'triggerfield',
			triggerCls : 'x-form-search-trigger',
			id : 'newInsTypeTrigField',
			anchor : '36%',
			style : 'float:right;',
			emptyText : 'Search Funds',
			listeners : {
				specialkey : function(field, e) {
					if (e.getKey() == e.ENTER) {
						Ext.Msg.alert('HI', 'Press Enter');
						field.fireEvent('onTriggerClick');
					}
				}
			},
			onTriggerClick : function() {
				Ext.data.StoreManager.lookup('fundContactStore').removeAll();
				Ext.data.StoreManager.lookup('parchasableInsStore').removeAll();
				Ext.data.StoreManager.lookup('salableInsStore').removeAll();
				Ext.data.StoreManager.lookup('repoableInsStore').removeAll();
				Ext.data.StoreManager.lookup('rRepoableInsStore').removeAll();
				Ext.data.StoreManager.lookup('fdIssuerStore').removeAll();
				Ext.ComponentQuery.query('#newFundStatusLbl')[0].setText('');
				Ext.ComponentQuery.query('#newFundCreatedLbl')[0].setText('');
				Ext.ComponentQuery.query('#newFundModifiedLbl')[0].setText('');
				Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText('');

				var newInsTypeTrigField = Ext.ComponentQuery.query('#newInsTypeTrigField')[0];
				Ext.Ajax.request({
					url : 'getFundNames.action',
					params : {
						querry : newInsTypeTrigField.getValue()
					},
					success : function(response) {
						var obj = Ext.decode(response.responseText);
						fundStore.loadRawData(obj.fundList);
					}
				});

				var formPnl = Ext.ComponentQuery.query('#NewFundFormPanel')[0];
				formPnl.getForm().reset();
				formPnl.getForm().applyToFields({
					disabled : false
				});

				var resultWindow = Ext.create('Ext.grid.Panel', {
					defaults : {
						anchor : '100%'
					},
					store : fundStore,
					columns : [ {
						text : 'ID',
						dataIndex : 'id',
						flex : 1
					}, {
						text : 'Code',
						dataIndex : 'fundCode',
						flex : 2
					}, {
						text : 'Name',
						dataIndex : 'fundName',
						flex : 4
					}, {
						text : 'Status',
						dataIndex : 'status',
						flex : 2
					} ],
					listeners : {
						itemdblclick : function(view, rec, item, index, eventObj) {
							var findId = rec.get('id');
							var formPanl = Ext.ComponentQuery.query('#NewFundFormPanel')[0];

							var allInsStore = Ext.data.StoreManager.lookup('allInsTypeStore');
							var allFDIssuers = Ext.data.StoreManager.lookup('allFdIssuersType');// Malsha
							var allInsStore_p = Ext.data.StoreManager.lookup('allInsTypeStore_P');// malsha
							var allInsStore_S = Ext.data.StoreManager.lookup('allInsTypeStore_S');// malsha
							var allInsStore_R = Ext.data.StoreManager.lookup('allInsTypeStore_R');// malsha
							var allInsStore_RR = Ext.data.StoreManager.lookup('allInsTypeStore_RR');// malsha

							var fundContactStore = Ext.data.StoreManager.lookup('fundContactStore');
							var purchasableIns = Ext.data.StoreManager.lookup('parchasableInsStore');
							var salableIns = Ext.data.StoreManager.lookup('salableInsStore');
							var repoableInStore = Ext.data.StoreManager.lookup('repoableInsStore');
							var rRepoableInStore = Ext.data.StoreManager.lookup('rRepoableInsStore');
							var fdIssuerStore = Ext.data.StoreManager.lookup('fdIssuerStore');

							var statusLbl = Ext.ComponentQuery.query('#newFundStatusLbl')[0];
							var createLbl = Ext.ComponentQuery.query('#newFundCreatedLbl')[0];
							var modifiedLbl = Ext.ComponentQuery.query('#newFundModifiedLbl')[0];
							var balanceLbl = Ext.ComponentQuery.query('#newFundBalanceLbl')[0];
							var updateBtn = Ext.getCmp('newFundUpdateBtn');
							var saveBtn = Ext.getCmp('newFundSaveBtn');
							var confirmBtn = Ext.getCmp('newFundConfirmBtn');

							formPanel.setLoading('Receiving data...', formPanl.getForm());
							// this.up('.window').setLoading('Receiving
							// data...', formPanl.getForm());
							if (true === false) { // If only viewing
								// permissions
								formPanl.getForm().applyToFields({
									disabled : true
								});
								saveBtn.setVisible(false);
								confirmBtn.setVisible(false);
								updateBtn.setVisible(false);
							} else {
								saveBtn.enable();
								saveBtn.setVisible(false);
								if (rec.get('status') === 'Initial') {
									confirmBtn.setVisible(true);
									updateBtn.setVisible(false);

								} else {
									confirmBtn.setVisible(false);
									updateBtn.setVisible(true);
								}
							}

							formPanl.getForm().load(
									{
										url : 'querryFund.action',
										params : {
											id : findId
										},
										success : function(response) {
											Ext.Ajax.request({
												url : 'querryFund.action',
												params : {
													id : findId
												},
												success : function(response) {
													var obj = Ext.decode(response.responseText);
													createLbl.setText('Created by: ' + obj.data.createdBy + ' on ' + obj.data.createdDate);
													statusLbl.setText('Fund Status: ' + obj.data.status);
													balanceLbl.setText('Unit Value: ' + obj.data.unitVal + ' Portfolio: ' + obj.data.portFolioVal + ' Last updated on: '
															+ obj.data.updateDate);
													if (obj.data.modifiedBy === null) {
														modifiedLbl.setText('');
													} else {
														modifiedLbl.setText('Last Updated by: ' + obj.data.modifiedBy + ' on ' + obj.data.modifiedDate);
													}
													var CCPArray = obj.data.custodianContactPersons.split(";");
													var i;
													for (i = 0; i < CCPArray.length; i++) {
														var Ccp = CCPArray[i].split(',');
														var fundContact = Ext.create('FundContact', {
															name : Ccp[1],
															designation : Ccp[2],
															phone : Ccp[3],
															fax : Ccp[4],
															email : Ccp[5]
														});
														fundContactStore.add(fundContact);
													}
													if (!(!obj.data.purchasableIns || 0 === obj.data.purchasableIns.length)) {
														var purchInsArray = obj.data.purchasableIns.split(";");
														i = 0;
														for (i = 0; i < purchInsArray.length - 1; i++) {
															var purchIns = allInsStore_p.findRecord('id', purchInsArray[i]);
															purchasableIns.add(purchIns);
														}
														for (i = 0; i < purchInsArray.length - 1; i++) {
															var purchIns = allInsStore_p.findRecord('id', purchInsArray[i]);
															allInsStore_p.remove(purchIns);
														}
													}
													if (!(!obj.data.salableIns || 0 === obj.data.salableIns.length)) {
														var salableInsArray = obj.data.salableIns.split(";");
														i = 0;
														for (i = 0; i < salableInsArray.length - 1; i++) {
															var saleIns = allInsStore_S.findRecord('id', salableInsArray[i]);
															salableIns.add(saleIns);
														}
														for (i = 0; i < salableInsArray.length - 1; i++) {
															var purchIns = allInsStore_S.findRecord('id', salableInsArray[i]);
															allInsStore_S.remove(purchIns);
														}
													}

													if (!(!obj.data.repoableIns || 0 === obj.data.repoableIns.length)) {
														var repoableInsArray = obj.data.repoableIns.split(";");
														i = 0;
														for (i = 0; i < repoableInsArray.length - 1; i++) {
															var repoableIns = allInsStore_R.findRecord('id', repoableInsArray[i]);
															repoableInStore.add(repoableIns);
														}
														for (i = 0; i < repoableInsArray.length - 1; i++) {
															var repoableIns = allInsStore_R.findRecord('id', repoableInsArray[i]);
															allInsStore_R.remove(repoableIns);
														}
													}

													if (!(!obj.data.rRepoableIns || 0 === obj.data.rRepoableIns.length)) {
														var rRepoableInsArray = obj.data.rRepoableIns.split(";");
														i = 0;
														for (i = 0; i < rRepoableInsArray.length - 1; i++) {
															var rRepoableIns = allInsStore_RR.findRecord('id', rRepoableInsArray[i]);
															rRepoableInStore.add(rRepoableIns);
														}
														for (i = 0; i < rRepoableInsArray.length - 1; i++) {
															var rRepoableIns = allInsStore_RR.findRecord('id', rRepoableInsArray[i]);
															allInsStore_RR.remove(rRepoableIns);
														}
													}

													if (!(!obj.data.fdIssuers || 0 === obj.data.fdIssuers.length)) {
														console.log(obj.data.fdIssuers);
														var fdIssuerArray = obj.data.fdIssuers.split(";");
														i = 0;
														for (i = 0; i < fdIssuerArray.length - 1; i++) {
															var fdIssuer = allFDIssuers.findRecord('id', fdIssuerArray[i]);
															fdIssuerStore.add(fdIssuer);
														}
														for (i = 0; i < fdIssuerArray.length - 1; i++) {
															var fdIssuer = allFDIssuers.findRecord('id', fdIssuerArray[i]);
															allFDIssuers.remove(fdIssuer);
														}
													}
													formPanel.setLoading(false);
												}

											});

										},
										failure : function(form, action) {
											formPanel.setLoading(false);
											Ext.Msg.alert("An Error occured. Load failed");
											formPanel.getForm().reset();
											formPanel.getForm().applyToFields({
												disabled : false
											});
											fundContactStore.removeAll();
											purchasableIns.removeAll();
											salableIns.removeAll();
											repoableInStore.removeAll();
											rRepoableInStore.removeAll();
											fdIssuerStore.removeAll();
											// saveBtn.enable();
											// saveBtn.setVisible(true);
											createLbl.setText('');
											statusLbl.setText('');
											modifiedLbl.setText('');
										}
									});

							// this.up('.window').setLoading(false);
							this.up('.window').close();
							Ext.ComponentQuery.query('#newInsTypeTrigField')[0].enable();
						}
					}
				});

				Ext.create('Ext.window.Window', {
					title : 'Search Results',
					height : 300,
					frame : true,
					width : 400,
					constrain : true,
					resizable : false,
					modal : true,
					layout : {
						type : 'fit'
					},
					items : [ resultWindow ]
				}).show();
			}
		} ]
	});
};

Fund.getFieldSet1 = function() {

	var fundManager = Ext.create('Ext.data.Store', {
		fields : [ 'id', 'fullName', 'designation' ]
	});

	Ext.Ajax.request({
		url : 'getFundManagers.action',
		success : function(response) {
			var obj = Ext.decode(response.responseText);
			fundManager.loadRawData(obj.fundManagerList);
		}
	});

	return Ext.create('Ext.form.FieldSet', {
		title : 'Basic',
		defaults : {
			anchor : '100%'
		},

		items : [ {
			xtype : 'label',
			id : 'newFundCodeValidLbl',
			text : ''
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ {
				xtype : 'textfield',
				name : 'name',
				fieldLabel : 'Name<span style="color:red">*</span>',
				allowBlank : false,
				blankText : 'Name cannot be null',
				emptyText : 'Name of the Fund',
				maxLength : 60,
				flex : 1,
				padding : '0 10 0 0',
				maxLengthText : 'Name is too long. Maximum 60 characters allowed!',
				msgTarget : 'under'
			}, {
				xtype : 'textfield',
				name : 'code',
				fieldLabel : 'Code<span style="color:red">*</span>',
				allowBlank : false,
				flex : 1,
				id : 'newFundCode',
				padding : '0 10 0 0',
				blankText : 'Code cannot be null',
				emptyText : 'Code of the Fund',
				maxLength : 20,
				maxLengthText : 'Code is too long. Maximum 20 characters allowed!',
				msgTarget : 'under',
				listeners : {
					blur : function() {
						var fundCode = this.value;
						if (fundCode.trim() === '') {
							Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText('Fund Code is Invalid!');
							Ext.ComponentQuery.query('#newFundCode')[0].reset();
						} else {
							Ext.Ajax.request({
								url : 'validFundCode.action',
								params : {
									querry : fundCode
								},
								success : function(response) {
									var obj = Ext.decode(response.responseText);
									if (obj.success) {
										Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText(fundCode + ' is OK');
									} else {
										Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText(fundCode + ' is Already Used!');
										Ext.ComponentQuery.query('#newInsTypeName')[0].reset();
									}
								},
								failure : function(response) {
									Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText('Fund Code Validation Failed!');
									this.reset();
								}
							});
						}
					}
				}
			} ]
		}, {
			xtype : 'label',
			id : 'newFundStatusLbl',
			style : 'font-weight:600;',
			text : ''
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ Ext.create('Ext.form.ComboBox', {
				fieldLabel : 'Fund Manager<span style="color:red">*</span>',
				store : fundManager,
				queryMode : 'local',
				// displayField:'name',
				valueField : 'id',
//				autoScroll : true,
				allowBlank : false,
				name : 'fundManagerId',
				editable : false,
				enableKeyEvents : true,
				flex : 1,
				padding : '0 10 0 0',
				tpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '<div class="x-boundlist-item">{fullName}, <i>{designation}<br/></div>', '</tpl>'),
				displayTpl : Ext.create('Ext.XTemplate', '<tpl for=".">', '{fullName}', '</tpl>'),
				listeners : {
					keydown : function(obj, e) {
						if (e.getCharCode() == e.BACKSPACE) {
							e.preventDefault();
						}
					}
				}
			}), {
				xtype : 'textfield',
				name : 'cdsAccount',
				fieldLabel : 'CDS Account<span style="color:red">*</span>',
				allowBlank : false,
				blankText : 'CDS Account cannot be null',
				emptyText : 'Relevant CDS Account Number',
				maxLength : 80,
				flex : 1,
				padding : '0 10 0 0',
				maxLengthText : 'Code is too long. Maximum 80 characters allowed!',
				msgTarget : 'under'
			} ]
		}, {
			xtype : 'textareafield',
			name : 'description',
			fieldLabel : 'Description',
			emptyText : 'Notes ...',
//			autoScroll : true,
			padding : '0 10 0 0',
			maxLength : 300,
			maxLengthText : 'Only 300 characters allowed',
			msgTarget : 'under'
		}, {
			name : 'trustDeedDate',
			fieldLabel : 'Trust Deed Date<span style="color:red">*</span>',
			xtype : 'datefield',
			format : 'd/m/Y',
			allowBlank : false,
			anchor : '48%'
		}, {
			xtype : 'fieldcontainer',
			layout : 'vbox',
			items : [ {
				xtype : 'label',
				id : 'newFundCreatedLbl',
				text : ''
			}, {
				xtype : 'label',
				id : 'newFundModifiedLbl',
				text : ''
			}, {
				xtype : 'label',
				id : 'newFundBalanceLbl',
				text : ''
			} ]
		} ]

	});
};

Fund.getFieldSet2 = function() {

	Ext.define('UTMS.newFund.CustodianModel', {
		extend : 'Ext.data.Model',
		fields : [ {
			name : 'id',
			type : 'int'
		}, {
			name : 'name',
			type : 'string'
		}, {
			name : 'description',
			type : 'string'
		} ]
	});

	var custodians = Ext.create('Ext.data.Store', {
		model : 'UTMS.newFund.CustodianModel'
	});

	Ext.Ajax.request({
		url : 'getCustodians.action',
		success : function(response) {
			var obj = Ext.decode(response.responseText);
			custodians.loadRawData(obj.custodianList);
		}
	});

	Ext.define('FundContact', {
		extend : 'Ext.data.Model',
		fields : [ {
			name : 'name',
			type : 'string'
		}, {
			name : 'designation',
			type : 'string'
		}, {
			name : 'phone',
			type : 'string'
		}, {
			name : 'fax',
			type : 'string'
		}, {
			name : 'email',
			type : 'string'
		} ]
	});

	var fundContactStore = new Ext.data.Store({
		model : 'FundContact',
		storeId : 'fundContactStore'
	});

	var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
		clicksToMoveEditor : 2,
		autoCancel : false
	});

	return Ext.create('Ext.form.FieldSet', {
		title : 'Custodian Details',
		defaults : {
			anchor : '100%'
		},
		items : [ {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ Ext.create('Ext.form.ComboBox', {
				fieldLabel : 'Custodian<span style="color:red">*</span>',
				store : custodians,
				queryMode : 'local',
				displayField : 'name',
				valueField : 'id',
				name : 'custodianId',
				autoSelect : true,
				allowBlank : false,
				flex : 1,
				padding : '0 10 0 0',
				editable : false,
				enableKeyEvents : true,
				listeners : {
					keydown : function(obj, e) {
						if (e.getCharCode() == e.BACKSPACE) {
							e.preventDefault();
						}
					}
				}
			}), {
				xtype : 'textfield',
				name : 'accountNo',
				fieldLabel : 'Account Number<span style="color:red">*</span>',
				allowBlank : false,
				flex : 1,
				padding : '0 10 0 0',
				// style : 'margin-bottom:5px;',
				blankText : 'Account No cannot be null',
				emptyText : 'Bank Account Number',
				maxLength : 60,
				maxLengthText : 'Account No is too long. Maximum 60 characters allowed!',
				msgTarget : 'under'
			} ]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ {
				xtype : 'textfield',
				name : 'custodianContactName',
				id : 'newFundCustContName',
				fieldLabel : 'Contact Person',
				// allowBlank : false,
				flex : 1,
				padding : '0 10 0 0',
				// style : 'margin-bottom:5px;',
				blankText : 'Contact Person is required',
				emptyText : 'Name of the Custodian Contact',
				maxLength : 100,
				maxLengthText : 'Name is too long. Maximum 100 characters allowed!',
				msgTarget : 'under'
			}, {
				xtype : 'textfield',
				fieldLabel : 'Designation',
				id : 'newFundCustContDesig',
				name : 'custodianContactDesig',
				flex : 1,
				padding : '0 10 0 0',
			// style : 'margin-bottom:5px;'
			} ]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			fieldLabel : 'Contact Details',
			fieldDefaults : {
				labelAlign : 'top'
			},
			items : [ {
				xtype : 'textfield',
				name : 'custodianContactNo',
				fieldLabel : 'Phone',
				id : 'newFundCustContPhone',
				// allowBlank : false,
				flex : 1,
				padding : '0 10 0 0',
				// style : 'margin-bottom:5px;',
				maskRe : new RegExp(/^\d{1}$/),
				// blankText : 'Contact No cannot be null',
				emptyText : '0xxxxxxxxx',
				minLength : 10,
				minLengthText : 'Number is too short!',
				msgTarget : 'under'
			}, {
				xtype : 'textfield',
				name : 'custodianContactFax',
				fieldLabel : 'Fax',
				flex : 1,
				id : 'newFundCustContFax',
				// style : 'margin-bottom:5px;',
				// allowBlank : false,
				// blankText : 'FAX Number cannot be null',
				emptyText : '0xxxxxxxxx',
				minLength : 10,
				maskRe : new RegExp(/^\d{1}$/),
				padding : '0 10 0 0',
				minLengthText : 'Number is too short!',
				msgTarget : 'under'
			}, {
				xtype : 'textfield',
				vtype : 'email',
				flex : 1,
				padding : '0 10 0 0',
				// style : 'margin-bottom:5px;',
				id : 'newFundCustContMail',
				name : 'custodianContactEmail',
				fieldLabel : 'E-mail',
				// /allowBlank : false,
				blankText : 'Email cannot be null',
				emptyText : 'abc@custodian.com'
			} ]
		}, Ext.create('Ext.grid.Panel', {
			id : 'newFundFundContactPanel',
			store : Ext.data.StoreManager.lookup('fundContactStore'),
			autoHeight : true,
			columns : [ {
				text : 'Name',
				dataIndex : 'name',
				flex : 3,
				editor : {}
			}, {
				text : 'Designation',
				dataIndex : 'designation',
				flex : 2,
				editor : {}
			}, {
				text : 'Phone',
				dataIndex : 'phone',
				flex : 2,
				editor : {}
			}, {
				text : 'Fax',
				dataIndex : 'fax',
				flex : 2,
				editor : {}
			}, {
				text : 'Email',
				dataIndex : 'email',
				flex : 3,
				editor : {
					vtype : 'email'
				}
			} ],
			width : 500,
			tbar : [ '->', {
				text : 'Add',
				id : 'newFundAddContactBtn',
				handler : function() {
					rowEditing.cancelEdit();
					var tfcontName = Ext.ComponentQuery.query('#newFundCustContName')[0];
					var tfcontPhone = Ext.ComponentQuery.query('#newFundCustContPhone')[0];
					var tfcontMail = Ext.ComponentQuery.query('#newFundCustContMail')[0];
					var tfcontFax = Ext.ComponentQuery.query('#newFundCustContFax')[0];
					var tfcontDesig = Ext.ComponentQuery.query('#newFundCustContDesig')[0];
					if (tfcontName.getValue() == '') {
						Ext.MessageBox.alert('Error', 'Please specify the contact name.');
					} else if (tfcontPhone.getValue() == '') {
						Ext.MessageBox.alert('Error', 'Please specify the contact phone.');
					} else if (tfcontMail.getValue() == '') {
						Ext.MessageBox.alert('Error', 'Please specify the contact mail.');
					} else {
						var recordIndex = fundContactStore.findBy(function(record, id) {
							if (record.get('name') === tfcontName.getValue()) {
								return true;
							}
							return false;
						});
						if (recordIndex != -1) {
							Ext.MessageBox.alert('Error!', 'Duplicate Name Found!!!');
						} else {
							var contactEntry = Ext.ModelManager.create({
								name : tfcontName.getValue(),
								designation : tfcontDesig.getValue(),
								phone : tfcontPhone.getValue(),
								fax : tfcontFax.getValue(),
								email : tfcontMail.getValue()
							}, 'FundContact');
							fundContactStore.add(contactEntry);
							// var pagingToolbar =
							// Ext.ComponentQuery.query('#newFundContactGridToolBar')[0];
							fundContactStore.totalCount = fundContactStore.count();
							// pagingToolbar.onLoad();
							Ext.ComponentQuery.query('#newFundCustContName')[0].reset();
							Ext.ComponentQuery.query('#newFundCustContDesig')[0].reset();
							Ext.ComponentQuery.query('#newFundCustContPhone')[0].reset();
							Ext.ComponentQuery.query('#newFundCustContFax')[0].reset();
							Ext.ComponentQuery.query('#newFundCustContMail')[0].reset();
						}

					}
				}
			}, {
				text : 'Remove',
				handler : function() {
					rowEditing.cancelEdit();
					var collateralsStore = Ext.data.StoreManager.lookup('fundContactStore');
					var pCpnDtStorePanel = Ext.ComponentQuery.query('#newFundFundContactPanel')[0];

					var sm = pCpnDtStorePanel.getSelectionModel();
					var sel = sm.getSelection();
					pCpnDtStorePanel.store.remove(sel[0]);

					var pagingToolbar = Ext.ComponentQuery.query('#newFundContactGridToolBar')[0];
					collateralsStore.totalCount = collateralsStore.count();
					pagingToolbar.onLoad();
				}
			} ],
			plugins : [ rowEditing ]

		})

		]
	});
};

Fund.getFieldSet3 = function() {

	return Ext.create('Ext.form.FieldSet', {
		title : 'Fund Category',
		items : [ {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			fieldLabel : 'Fund Category',
			defaultType : 'radiofield',
			items : [ {
				boxLabel : 'FIS',
				name : 'fundCategory',
				inputValue : 'fis',
				id : 'radiofis',
				padding : '0 20 0 0',
				listeners : {
					change : function(field, newValue, oldValue) {
						if (newValue) {
							var filedSet4 = Ext.ComponentQuery.query('#filedSet4')[0];
							filedSet4.setVisible(true);
							var saveButton = Ext.ComponentQuery.query('#saveButton')[0];
							saveButton.enable();
						}
					}

				}
			}, {
				boxLabel : 'Equity',
				name : 'fundCategory',
				inputValue : 'equity',
				id : 'radioequity',
				checked : true,
				listeners : {
					change : function(field, newValue, oldValue) {
						if (newValue) {
							var filedSet4 = Ext.ComponentQuery.query('#filedSet4')[0];
							filedSet4.setVisible(false);

							var saveButton = Ext.ComponentQuery.query('#saveButton')[0];
							saveButton.disable();
						}
					}

				}
			} ]
		} ]
	});
};

Fund.getFieldSet4 = function() {
	Ext.define('FundInstrumentType', {
		extend : 'Ext.data.Model',
		fields : [ {
			name : 'id',
			type : 'int'
		}, {
			name : 'instrumentName',
			type : 'string'
		}, {
			name : 'istrumentType',
			type : 'int'
		}, {
			name : 'scripts',
			type : 'int'
		}, {
			name : 'denominals',
			type : 'int'
		}, {
			name : 'listed',
			type : 'int'
		}, {
			name : 'withholdingTax',
			type : 'string'
		}, {
			name : 'interestRate',
			type : 'string'
		}, {
			name : 'interestType',
			type : 'string'
		}, {
			name : 'dayBasis',
			type : 'string'
		}, {
			name : 'couponAvailability',
			type : 'int'
		}, {
			name : 'cuponFrequency',
			type : 'int'
		}, {
			name : 'shortMaturable',
			type : 'int'
		} ]
	});

	var instrumentTypeStore = new Ext.data.Store({
		model : 'FundInstrumentType',
		storeId : 'allInsTypeStore'
	});

	var instrumentTypeStore_P = new Ext.data.Store({
		model : 'FundInstrumentType',
		storeId : 'allInsTypeStore_P'
	});
	var instrumentTypeStore_S = new Ext.data.Store({
		model : 'FundInstrumentType',
		storeId : 'allInsTypeStore_S'
	});
	var instrumentTypeStore_R = new Ext.data.Store({
		model : 'FundInstrumentType',
		storeId : 'allInsTypeStore_R'
	});

	var instrumentTypeStore_RR = new Ext.data.Store({
		model : 'FundInstrumentType',
		storeId : 'allInsTypeStore_RR'
	});

	Ext.Ajax.request({
		url : 'getInstrumentTypes.action',
		success : function(response) {
			var obj = Ext.decode(response.responseText);
			instrumentTypeStore.loadRawData(obj.instrumentTypeList);
			instrumentTypeStore_P.loadRawData(obj.instrumentTypeList);
			instrumentTypeStore_S.loadRawData(obj.instrumentTypeList);
			instrumentTypeStore_R.loadRawData(obj.instrumentTypeList);
			instrumentTypeStore_RR.loadRawData(obj.instrumentTypeList);
		}
	});

	var parchasableInsStore = Ext.create('Ext.data.Store', {
		storeId : 'parchasableInsStore',
		model : 'FundInstrumentType'
	});

	var salableInsStore = Ext.create('Ext.data.Store', {
		storeId : 'salableInsStore',
		model : 'FundInstrumentType'
	});

	var repoableInsStore = Ext.create('Ext.data.Store', {
		storeId : 'repoableInsStore',
		model : 'FundInstrumentType'
	});

	var rRepoableInsStore = Ext.create('Ext.data.Store', {
		storeId : 'rRepoableInsStore',
		model : 'FundInstrumentType'
	});

	Ext.define('FDIssuerModel', {
		extend : 'Ext.data.Model',
		fields : [ {
			name : 'id',
			type : 'int'
		}, {
			name : 'code',
			type : 'string'
		}, {
			name : 'name',
			type : 'String'
		} ]
	});

	Ext.define('FDIssuerTypeModel', {
		extend : 'Ext.data.Model',
		fields : [ {
			name : 'id',
			type : 'int'
		}, {
			name : 'code',
			type : 'string'
		}, {
			name : 'issureCategory',
			type : 'string'
		}, {
			name : 'primaryDealer'
		} ]
	});

	var issuersTypeListStore = new Ext.data.Store({
		model : 'FDIssuerTypeModel',
		storeId : 'allFdIssuersType'
	});

	Ext.Ajax.request({
		url : 'getAllIssuerTypes.action',
		success : function(response) {
			var obj = Ext.decode(response.responseText);
			issuersTypeListStore.loadRawData(obj.issuerTypeDtos);
		}
	});

	var fdIssuerStore = Ext.create('Ext.data.Store', {
		storeId : 'fdIssuerStore',
		model : 'FDIssuerTypeModel',
	});

	var valuationMethods = Ext.create('Ext.data.Store', {
		fields : [ 'method' ],
		data : [ {
			"method" : "Cost+Accrual"
		}, {
			"method" : "Mark to Market"
		} ]
	});

	var instruments = Ext.create('Ext.data.Store', {
		fields : [ 'type' ],
		data : [ {
			"type" : "TBill "
		}, {
			"type" : "TBond "
		}, {
			"type" : "CommercialPaper "
		}, {
			"type" : "Debenture "
		}, {
			"type" : "TrustCertificate "
		} ]
	});
	// *************************** not use ************************//
	var issuersListStore = new Ext.data.Store({
		model : 'FDIssuerModel',
		storeId : 'allFdIssuers'

	});

	Ext.Ajax.request({
		url : 'getIssuers.action',
		success : function(response) {
			var obj = Ext.decode(response.responseText);
			issuersListStore.loadRawData(obj.issuerList);
		}
	});

	return Ext.create('Ext.form.FieldSet', {
		title : 'Fixed Income Security Parameters',
		collapsible : true,
		itemId : 'filedSet4',
		defaults : {
			anchor : '100%'
		},
		items : [ Ext.create('Ext.form.ComboBox', {
			fieldLabel : 'Valuation Method',
			store : valuationMethods,
			name : 'valuationMethod',
			queryMode : 'local',
			valueField : 'method',
			displayField : 'method',
			allowBlank : false,
			anchor : '50%',
			value : 'Cost+Accrual',
			editable : false,
			enableKeyEvents : true,
			listeners : {
				keydown : function(obj, e) {
					if (e.getCharCode() == e.BACKSPACE) {
						e.preventDefault();
					}
				}
			}
		}), Ext.create('Ext.form.FieldSet', {
			title : 'Deal Types',
			padding : '0 5 0 5',
			items : [ {
				xtype : 'fieldcontainer',
				fieldLabel : 'Select the Deal Types',
				defaultType : 'checkboxfield',
				layout : 'hbox',
				padding : '0 5 0 5',
				items : [ {
					boxLabel : 'Purchase',
					name : 'purchaseDeals',
					inputValue : true,
					flex : 1,
					id : 'checkbox1',
					listeners : {
						change : function() {
							var purchCont = Ext.ComponentQuery.query('#newFundPurchasableCont')[0];
							if (this.value) {
								purchCont.show();
							} else {
								purchCont.hide();
							}
						}
					}
				}, {
					boxLabel : 'Sale',
					name : 'saleDeals',
					inputValue : true,
					// checked : true,
					flex : 1,
					id : 'checkbox2',
					listeners : {
						change : function() {
							var purchCont = Ext.ComponentQuery.query('#newFundSalabaleCont')[0];
							if (this.value) {
								purchCont.show();
							} else {
								purchCont.hide();
							}
						}
					}
				}, {
					boxLabel : 'Fixed Deposites',
					name : 'fdDeals',
					inputValue : true,
					flex : 1,
					id : 'checkbox3',
					listeners : {
						change : function() {
							var fdCont = Ext.ComponentQuery.query('#newFundFDIssuersCont')[0];
							if (this.value) {
								fdCont.show();
							} else {
								fdCont.hide();
							}
						}
					}
				}, {
					boxLabel : 'Repo',
					name : 'repoDeals',
					inputValue : true,
					flex : 1,
					// checked : true,
					id : 'checkbox4',
					listeners : {
						change : function() {
							var purchCont = Ext.ComponentQuery.query('#newFundRepoableCont')[0];
							if (this.value) {
								purchCont.show();
							} else {
								purchCont.hide();
							}
						}
					}
				}, {
					boxLabel : 'Reverse Repo',
					name : 'revRepoDeals',
					inputValue : true,
					flex : 1,
					// checked : true,
					id : 'checkbox5',
					listeners : {
						change : function() {
							var purchCont = Ext.ComponentQuery.query('#newFundRRepoableCont')[0];
							if (this.value) {
								purchCont.show();
							} else {
								purchCont.hide();
							}
						}
					}
				} ]
			}, {
				xtype : 'button',
				text : 'Select All',
				padding : '0 20 0 20',
				width : '20px',
				handler : function() {
					Ext.getCmp('checkbox1').setValue(true);
					Ext.getCmp('checkbox2').setValue(true);
					Ext.getCmp('checkbox3').setValue(true);
					Ext.getCmp('checkbox4').setValue(true);
					Ext.getCmp('checkbox5').setValue(true);
				}
			}, {
				xtype : 'button',
				text : 'Deselect All',
				padding : '0 20 0 20',
				// enableToggle : true,
				width : '20px',
				handler : function() {
					Ext.getCmp('checkbox1').setValue(false);
					Ext.getCmp('checkbox2').setValue(false);
					Ext.getCmp('checkbox3').setValue(false);
					Ext.getCmp('checkbox4').setValue(false);
					Ext.getCmp('checkbox5').setValue(false);
				}
			} ]
		}), {
			xtype : 'fieldcontainer',
			autoHeight : true,
			id : 'newFundAccordian',
			layout : {
				type : 'vbox',
			},
			items : [ {
				title : 'Instruments Allowed for Purchase',
				layout : 'hbox',
				hidden : true,
				id : 'newFundPurchasableCont',
				items : [ Ext.create('Ext.grid.Panel', {
					store : instrumentTypeStore_P,
					width : 200,
					id : 'grid1',
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}), {
					xtype : 'buttongroup',
					columns : 1,
					padding : '25 0 0 0',
					height : 154,
					buttonAlign : 'center',
					items : [ {
						text : '>',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('grid1').getView().getSelectionModel().getSelection();
							if (selection) {
								Ext.data.StoreManager.lookup('parchasableInsStore').add(selection);
								instrumentTypeStore_P.remove(selection);
							}
						}
					}, {
						text : '<',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('grid2').getView().getSelectionModel().getSelection();
							if (selection) {
								instrumentTypeStore_P.add(selection);
								Ext.data.StoreManager.lookup('parchasableInsStore').remove(selection);
							}
						}
					}, {
						text : '>>',
						width : 50,
						handler : function() {
							instrumentTypeStore_P.each(function(record) {
								Ext.data.StoreManager.lookup('parchasableInsStore').add(record);
							});
							instrumentTypeStore_P.removeAll();
						}
					}, {
						text : '<<',
						width : 50,
						handler : function() {
							Ext.data.StoreManager.lookup('parchasableInsStore').each(function(record) {
								instrumentTypeStore_P.add(record);
							});
							Ext.data.StoreManager.lookup('parchasableInsStore').removeAll();
						}
					} ]
				}, Ext.create('Ext.grid.Panel', {
					store : Ext.data.StoreManager.lookup('parchasableInsStore'),
					width : 200,
					id : 'grid2',
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}) ]
			}, {
				title : 'Instruments Allowed for Sale',
				layout : 'hbox',
				id : 'newFundSalabaleCont',
				hidden : true,
				items : [ Ext.create('Ext.grid.Panel', {
					id : 'saleGrid_1',
					store : instrumentTypeStore_S,
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}), {
					xtype : 'buttongroup',
					columns : 1,
					padding : '25 0 0 0',
					height : 154,
					buttonAlign : 'center',
					items : [ {
						text : '>',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('saleGrid_1').getView().getSelectionModel().getSelection();
							if (selection) {
								Ext.data.StoreManager.lookup('salableInsStore').add(selection);
								instrumentTypeStore_S.remove(selection);
							}
						}
					}, {
						text : '<',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('newDealSalableInsGrid').getView().getSelectionModel().getSelection();
							if (selection) {
								instrumentTypeStore_S.add(selection);
								Ext.data.StoreManager.lookup('salableInsStore').remove(selection);
							}
						}
					}, {
						text : '>>',
						width : 50,
						handler : function() {
							instrumentTypeStore_S.each(function(record) {
								Ext.data.StoreManager.lookup('salableInsStore').add(record);
							});
							instrumentTypeStore_S.removeAll();
						}
					}, {
						text : '<<',
						width : 50,
						handler : function() {
							Ext.data.StoreManager.lookup('salableInsStore').each(function(record) {
								instrumentTypeStore_S.add(record);
							});
							Ext.data.StoreManager.lookup('salableInsStore').removeAll();
						}
					} ]

				}, Ext.create('Ext.grid.Panel', {
					id : 'newDealSalableInsGrid',
					store : Ext.data.StoreManager.lookup('salableInsStore'),
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}) ]
			}, {
				title : 'Issuers Allowed with FD Deals',
				layout : 'hbox',
				id : 'newFundFDIssuersCont',
				hidden : true,
				items : [ Ext.create('Ext.grid.Panel', {
					id : 'issuertypegrid_1',
					store : issuersTypeListStore,
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'code',
						flex : 2
					}, {
						dataIndex : 'issureCategory',
						flex : 3
					} ]
				}), {
					xtype : 'buttongroup',
					columns : 1,
					padding : '25 0 0 0',
					height : 154,
					buttonAlign : 'center',
					items : [ {
						text : '>',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('issuertypegrid_1').getView().getSelectionModel().getSelection();
							if (selection) {
								Ext.data.StoreManager.lookup('fdIssuerStore').add(selection);
								issuersTypeListStore.remove(selection);
							}
						}
					}, {
						text : '<',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('newDealFDIssuerGrid').getView().getSelectionModel().getSelection();
							if (selection) {
								issuersTypeListStore.add(selection);
								Ext.data.StoreManager.lookup('fdIssuerStore').remove(selection);
							}
						}
					}, {
						text : '>>',
						width : 50,
						handler : function() {
							issuersTypeListStore.each(function(record) {
								Ext.data.StoreManager.lookup('fdIssuerStore').add(record);
							});
							issuersTypeListStore.removeAll();
						}
					}, {
						text : '<<',
						width : 50,
						handler : function() {
							Ext.data.StoreManager.lookup('fdIssuerStore').each(function(record) {
								issuersTypeListStore.add(record);
							});
							Ext.data.StoreManager.lookup('fdIssuerStore').removeAll();
						}
					} ]

				}, Ext.create('Ext.grid.Panel', {
					id : 'newDealFDIssuerGrid',
					store : Ext.data.StoreManager.lookup('fdIssuerStore'),
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'code',
						flex : 2
					}, {
						dataIndex : 'issureCategory',
						flex : 3
					} ]
				}) ]
			}, {
				title : 'Collaterals Allowed with Repo Deals',
				layout : 'hbox',
				id : 'newFundRepoableCont',
				hidden : true,
				items : [ Ext.create('Ext.grid.Panel', {
					id : 'repoGrid_1',
					store : instrumentTypeStore_R,
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}), {
					xtype : 'buttongroup',
					columns : 1,
					padding : '25 0 0 0',
					height : 154,
					buttonAlign : 'center',
					items : [ {
						text : '>',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('repoGrid_1').getView().getSelectionModel().getSelection();
							if (selection) {
								Ext.data.StoreManager.lookup('repoableInsStore').add(selection);
								instrumentTypeStore_R.remove(selection);
							}
						}
					}, {
						text : '<',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('newDealRepoableInsGrid').getView().getSelectionModel().getSelection();
							if (selection) {
								instrumentTypeStore_R.add(selection);
								Ext.data.StoreManager.lookup('repoableInsStore').remove(selection);
							}
						}
					}, {
						text : '>>',
						width : 50,
						handler : function() {
							instrumentTypeStore_R.each(function(record) {
								Ext.data.StoreManager.lookup('repoableInsStore').add(record);
							});
							instrumentTypeStore_R.removeAll();
						}
					}, {
						text : '<<',
						width : 50,
						handler : function() {
							Ext.data.StoreManager.lookup('repoableInsStore').each(function(record) {
								instrumentTypeStore_R.add(record);
							});
							Ext.data.StoreManager.lookup('repoableInsStore').removeAll();
						}
					} ]

				}, Ext.create('Ext.grid.Panel', {
					id : 'newDealRepoableInsGrid',
					store : Ext.data.StoreManager.lookup('repoableInsStore'),
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}) ]

			}, {
				title : 'Collaterals Allowed with Reverse Repo Deals',
				layout : 'hbox',
				id : 'newFundRRepoableCont',
				hidden : true,
				items : [ Ext.create('Ext.grid.Panel', {
					id : 'rrgrid_1',
					store : instrumentTypeStore_RR,
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}), {
					xtype : 'buttongroup',
					columns : 1,
					padding : '25 0 0 0',
					height : 154,
					buttonAlign : 'center',
					items : [ {
						text : '>',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('rrgrid_1').getView().getSelectionModel().getSelection();
							if (selection) {
								Ext.data.StoreManager.lookup('rRepoableInsStore').add(selection);
								instrumentTypeStore_RR.remove(selection);
							}
						}
					}, {
						text : '<',
						width : 50,
						handler : function() {
							var selection = Ext.getCmp('newDealRRepoableInsGrid').getView().getSelectionModel().getSelection();
							if (selection) {
								instrumentTypeStore_RR.add(selection);
								Ext.data.StoreManager.lookup('rRepoableInsStore').remove(selection);
							}
						}
					}, {
						text : '>>',
						width : 50,
						handler : function() {
							instrumentTypeStore_RR.each(function(record) {
								Ext.data.StoreManager.lookup('rRepoableInsStore').add(record);
							});
							instrumentTypeStore_RR.removeAll();
						}
					}, {
						text : '<<',
						width : 50,
						handler : function() {
							Ext.data.StoreManager.lookup('rRepoableInsStore').each(function(record) {
								instrumentTypeStore_RR.add(record);
							});
							Ext.data.StoreManager.lookup('rRepoableInsStore').removeAll();
						}
					} ]

				}, Ext.create('Ext.grid.Panel', {
					id : 'newDealRRepoableInsGrid',
					store : Ext.data.StoreManager.lookup('rRepoableInsStore'),
					width : 200,
					height : 154,
					flex : 1,
					hideHeaders : true,
					autoScroll : true,
					columns : [ {
						dataIndex : 'instrumentName',
						flex : 3
					} ]
				}) ]

			} ]
		} ]
	});
};

Fund.getFieldSet5 = function() {
	return Ext.create('Ext.form.FieldSet', {
		title : 'Fee Structure',
		defaults : {
			anchor : '100%'
		},
		items : [ {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			defaults : {
				anchor : '100%'
			},
			items : [ {
				xtype : 'fieldcontainer',
				fieldLabel : 'Custodian Fee',
				defaultType : 'radiofield',
				flex : 5,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Fixed Amount',
					name : 'custFeeMethod',
					inputValue : 'fixed',
					listeners : {
						change : function(field, newValue, oldValue) {
							var custFeeFreq = Ext.ComponentQuery.query('#newFundCustFeeFreq')[0];
							var custFeeAm = Ext.ComponentQuery.query('#newDealCustFeeAmount')[0];
							var custFeePer = Ext.ComponentQuery.query('#newDealCustFeePercentage')[0];
							if (newValue) {
								custFeeFreq.enable();
								custFeePer.hide();
								custFeePer.reset();
								custFeePer.disable();
								custFeePer.allowBlank = false;
								custFeeAm.show();
								custFeeAm.enable();
								custFeeAm.allowBlank = true;
							} else {
								custFeeFreq.disable();
								custFeeAm.hide();
								custFeeAm.reset();
								custFeeAm.disable();
								custFeeAm.allowBlank = false;
								custFeePer.show();
								custFeePer.enable();
								custFeePer.allowBlank = true;
							}
						}

					}
				}, {
					boxLabel : 'Percentage',
					name : 'custFeeMethod',
					inputValue : 'percent',
					checked : true
				} ]
			}, {
				xtype : 'fieldcontainer',
				defaultType : 'radiofield',
				id : 'newFundCustFeeFreq',
				flex : 2,
				disabled : true,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Annual',
					name : 'custFeeFreq',
					inputValue : 'annual',
					checked : true
				}, {
					boxLabel : 'Monthly',
					name : 'custFeeFreq',
					inputValue : 'monthly'
				} ]
			}, {
				flex : 5,
				padding : '0 5px 0 0',
				labelWidth : 50,
				xtype : 'textfield',
				minValue : 0,
				name : 'custFeeAmount',
				id : 'newDealCustFeeAmount',
				hidden : true,
				disabled : true,
				// allowBlank : false,
				fieldLabel : 'Amount',
				// emptyText : 'Amount for Custodian Fee',
				fieldStyle : "text-align:right;",
				maskRe : /[\d\,.%]/,
				listeners : {
					blur : function() {
						this.setRawValue(Ext.util.Format.number(this.value.replace(/,/g, ''), '0,000.0000'));
					}
				}
			}, {
				flex : 5,
				padding : '0 5px 0 0',
				labelWidth : 50,
				xtype : 'numberfield',
				minValue : 0,
				maxValue : 100,
				value : 0,
				forcePrecision : true,
				decimalPrecision : 4,
				allowBlank : false,
				name : 'custFeePercent',
				id : 'newDealCustFeePercentage',
				fieldLabel : 'Amount',
				fieldStyle : "text-align:right;"
			} ]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			defaults : {
				anchor : '100%'
			},
			items : [ {
				xtype : 'fieldcontainer',
				fieldLabel : 'Trustee Fee',
				defaultType : 'radiofield',
				flex : 5,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Fixed Amount',
					name : 'trusteeFeeMethod',
					inputValue : 'fixed',
					listeners : {
						change : function(field, newValue, oldValue) {
							var custFeeFreq = Ext.ComponentQuery.query('#newFundTrusteeFeeFreq')[0];
							var custFeeAm = Ext.ComponentQuery.query('#newDealTrusteeFeeAmount')[0];
							var custFeePer = Ext.ComponentQuery.query('#newDealTrusteeFeePercentage')[0];
							if (newValue) {
								custFeeFreq.enable();
								custFeePer.reset();
								custFeePer.hide();
								custFeePer.disable();
								custFeePer.allowBlank = false;
								custFeeAm.show();
								custFeeAm.enable();
								custFeeAm.allowBlank = true;
							} else {
								custFeeFreq.disable();
								custFeeAm.reset();
								custFeeAm.hide();
								custFeeAm.disable();
								custFeeAm.allowBlank = false;
								custFeePer.show();
								custFeePer.enable();
								custFeePer.allowBlank = true;
							}
						}

					}
				}, {
					boxLabel : 'Percentage',
					name : 'trusteeFeeMethod',
					inputValue : 'percent',
					checked : true
				} ]
			}, {
				xtype : 'fieldcontainer',
				defaultType : 'radiofield',
				id : 'newFundTrusteeFeeFreq',
				flex : 2,
				disabled : true,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Annual',
					name : 'trusteeFeeFreq',
					inputValue : 'annual',
					checked : true
				}, {
					boxLabel : 'Monthly',
					name : 'trusteeFeeFreq',
					inputValue : 'monthly'
				} ]
			}, {
				flex : 5,
				padding : '0 5px 0 0',
				labelWidth : 50,
				xtype : 'textfield',
				minValue : 0,
				name : 'trusteeFeeAmount',
				id : 'newDealTrusteeFeeAmount',
				hidden : true,
				disabled : true,
				// allowBlank : false,
				fieldLabel : 'Amount',
				// emptyText : 'Percentage/Amount for Trustee Fee',
				fieldStyle : "text-align:right;",
				maskRe : /[\d\,.%]/,
				listeners : {
					blur : function() {
						this.setRawValue(Ext.util.Format.number(this.value.replace(/,/g, ''), '0,000.0000'));
					}
				}
			}, {
				flex : 5,
				padding : '0 5px 0 0',
				labelWidth : 50,
				xtype : 'numberfield',
				minValue : 0,
				maxValue : 100,
				value : 0,
				forcePrecision : true,
				decimalPrecision : 4,
				allowBlank : false,
				name : 'trusteeFeePercent',
				id : 'newDealTrusteeFeePercentage',
				fieldLabel : 'Amount',
				fieldStyle : "text-align:right;"
			} ]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			defaults : {
				anchor : '100%'
			},
			items : [ {
				xtype : 'fieldcontainer',
				fieldLabel : 'Management Fee',
				defaultType : 'radiofield',
				flex : 5,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Fixed Amount',
					name : 'manageFeeMethod',
					inputValue : 'fixed',
					listeners : {
						change : function(field, newValue, oldValue) {
							var custFeeFreq = Ext.ComponentQuery.query('#newFundManageFeeFreq')[0];
							var custFeeAm = Ext.ComponentQuery.query('#newDealManageFeeAmount')[0];
							var custFeePer = Ext.ComponentQuery.query('#newDealManageFeePercentage')[0];
							if (newValue) {
								custFeeFreq.enable();
								custFeePer.reset();
								custFeePer.hide();
								custFeePer.disable();
								custFeePer.allowBlank = false;
								custFeeAm.show();
								custFeeAm.enable();
								custFeeAm.allowBlank = true;
							} else {
								custFeeFreq.disable();
								custFeeAm.reset();
								custFeeAm.hide();
								custFeeAm.disable();
								custFeeAm.allowBlank = false;
								custFeePer.show();
								custFeePer.enable();
								custFeePer.allowBlank = true;
							}
						}

					}
				}, {
					boxLabel : 'Percentage',
					name : 'manageFeeMethod',
					inputValue : 'percent',
					checked : true
				} ]
			}, {
				xtype : 'fieldcontainer',
				defaultType : 'radiofield',
				id : 'newFundManageFeeFreq',
				flex : 2,
				disabled : true,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Annual',
					name : 'manageFeeFreq',
					inputValue : 'annual',
					checked : true
				}, {
					boxLabel : 'Monthly',
					name : 'manageFeeFreq',
					inputValue : 'monthly'
				} ]
			}, {
				flex : 5,
				padding : '0 5px 0 0',
				labelWidth : 50,
				xtype : 'textfield',
				minValue : 0,
				name : 'manageFeeAmount',
				id : 'newDealManageFeeAmount',
				hidden : true,
				disabled : true,
				// allowBlank : false,
				fieldLabel : 'Amount',
				// emptyText : 'Percentage/Amount for Management Fee',
				fieldStyle : "text-align:right;",
				maskRe : /[\d\,.%]/,
				listeners : {
					blur : function() {
						this.setRawValue(Ext.util.Format.number(this.value.replace(/,/g, ''), '0,000.0000'));
					}
				}
			}, {
				flex : 5,
				padding : '0 5px 0 0',
				labelWidth : 50,
				xtype : 'numberfield',
				minValue : 0,
				maxValue : 100,
				value : 0,
				forcePrecision : true,
				decimalPrecision : 4,
				allowBlank : false,
				name : 'manageFeePercent',
				id : 'newDealManageFeePercentage',
				fieldLabel : 'Amount',
				fieldStyle : "text-align:right;"
			} ]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			defaults : {
				anchor : '100%'
			},
			items : [ {
				xtype : 'fieldcontainer',
				fieldLabel : 'Audit Fee',
				defaultType : 'radiofield',
				flex : 5,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Fixed Amount',
					name : 'auditFeeMethod',
					inputValue : 'fixed',
					listeners : {
						change : function(field, newValue, oldValue) {
							var custFeeFreq = Ext.ComponentQuery.query('#newFundAuditFeeFreq')[0];
							var custFeeAm = Ext.ComponentQuery.query('#newDealAuditFeeAmount')[0];
							var custFeePer = Ext.ComponentQuery.query('#newDealAuditFeePercentage')[0];
							if (newValue) {
								custFeeFreq.enable();
								custFeePer.reset();
								custFeePer.hide();
								custFeePer.disable();
								custFeePer.allowBlank = false;
								custFeeAm.show();
								custFeeAm.enable();
								custFeeAm.allowBlank = true;
							} else {
								custFeeFreq.disable();
								custFeeAm.reset();
								custFeeAm.hide();
								custFeeAm.disable();
								custFeeAm.allowBlank = false;
								custFeePer.show();
								custFeePer.enable();
								custFeePer.allowBlank = true;
							}
						}

					}
				}, {
					boxLabel : 'Percentage',
					name : 'auditFeeMethod',
					inputValue : 'percent',
					checked : true
				} ]
			}, {
				xtype : 'fieldcontainer',
				defaultType : 'radiofield',
				id : 'newFundAuditFeeFreq',
				flex : 2,
				disabled : true,
				layout : 'vbox',
				items : [ {
					boxLabel : 'Annual',
					name : 'auditFeeFreq',
					inputValue : 'annual',
					checked : true
				}, {
					boxLabel : 'Monthly',
					name : 'auditFeeFreq',
					inputValue : 'monthly'
				} ]
			}, {
				flex : 5,
				padding : '0 5 0 0',
				labelWidth : 50,
				xtype : 'textfield',
				minValue : 0,
				name : 'auditFeeAmount',
				id : 'newDealAuditFeeAmount',
				hidden : true,
				disabled : true,
				fieldLabel : 'Amount',
				emptyText : 'Percentage/Amount for Audit Fee',
				fieldStyle : "text-align:right;",
				maskRe : /[\d\,.%]/,
				listeners : {
					blur : function() {
						this.setRawValue(Ext.util.Format.number(this.value.replace(/,/g, ''), '0,000.0000'));
					}
				}
			}, {
				flex : 5,
				padding : '0 5 0 0',
				labelWidth : 50,
				xtype : 'numberfield',
				minValue : 0,
				maxValue : 100,
				value : 0,
				forcePrecision : true,
				decimalPrecision : 4,
				allowBlank : false,
				name : 'auditFeePercent',
				id : 'newDealAuditFeePercentage',
				fieldLabel : 'Amount',
				fieldStyle : "text-align:right;"
			} ]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',

			items : [ {
				xtype : 'numberfield',
				minValue : 0,
				maxValue : 100,
				value : 0,
				forcePrecision : true,
				decimalPrecision : 4,
				allowBlank : false,
				name : 'outboundCharge',
				fieldLabel : 'OPC',
				flex : 1,
				padding : '0 20 0 0',
				// style : 'margin-top:10px;',
				listeners : {
					render : function(p) {
						var theElem = p.getEl();
						var theTip = Ext.create('Ext.tip.Tip', {
							html : 'Out Performance Charge',
							margin : '20 0 0 0',
							shadow : false
						});

						p.getEl().on('mouseover', function() {
							theTip.showAt(theElem.getX(), theElem.getY());
						});

						p.getEl().on('mouseleave', function() {
							theTip.hide();
						});
					}
				}
			}, {
				xtype : 'numberfield',
				minValue : 0,
				maxValue : 100,
				value : 0,
				forcePrecision : true,
				decimalPrecision : 4,
				allowBlank : false,
				name : 'otherPercentageFee',
				fieldLabel : 'Other Fee(%)',
				flex : 1,
				padding : '0 5 0 0',
				listeners : {
					render : function(p) {
						var theElem = p.getEl();
						var theTip = Ext.create('Ext.tip.Tip', {
							html : 'As a percentage of the Portfolio Value',
							margin : '20 0 0 0',
							shadow : false
						});

						p.getEl().on('mouseover', function() {
							theTip.showAt(theElem.getX(), theElem.getY());
						});

						p.getEl().on('mouseleave', function() {
							theTip.hide();
						});
					}
				}
			}

			]
		}, {
			xtype : 'fieldcontainer',
			layout : 'hbox',
			items : [ {
				xtype : 'textfield',
				minValue : 0,
				name : 'fixedAnnualFee',
				flex : 1,
				value : 0,
				allowBlank : false,
				padding : '0 20 0 0',
				fieldLabel : 'Other Fee(Year)',
				fieldStyle : "text-align:right;",
				maskRe : /[\d\,.]/,
				listeners : {
					blur : function() {
						this.setRawValue(Ext.util.Format.number(this.value.replace(/,/g, ''), '0,000.0000'));
					},
					render : function(p) {
						this.setRawValue(Ext.util.Format.number(this.value, '0,000.0000'));

						var theElem = p.getEl();
						var theTip = Ext.create('Ext.tip.Tip', {
							html : 'ANNUALLY Charged FIXED Fees',
							margin : '20 0 0 0',
							shadow : false
						});

						p.getEl().on('mouseover', function() {
							theTip.showAt(theElem.getX(), theElem.getY());
						});

						p.getEl().on('mouseleave', function() {
							theTip.hide();
						});
					}
				}
			}, {
				xtype : 'textfield',
				minValue : 0,
				name : 'fixedMonthlyFee',
				flex : 1,
				value : 0,
				allowBlank : false,
				padding : '0 5 0 0',
				fieldLabel : 'Other Fee(Month)',
				fieldStyle : "text-align:right;",
				maskRe : /[\d\,.]/,
				listeners : {
					blur : function() {
						this.setRawValue(Ext.util.Format.number(this.value.replace(/,/g, ''), '0,000.0000'));
					},
					render : function(p) {
						this.setRawValue(Ext.util.Format.number(this.value, '0,000.0000'));

						var theElem = p.getEl();
						var theTip = Ext.create('Ext.tip.Tip', {
							html : 'MONTHLY Charged FIXED Fees',
							margin : '20 0 0 0',
							shadow : false
						});
						p.getEl().on('mouseover', function() {
							theTip.showAt(theElem.getX(), theElem.getY());
						});
						p.getEl().on('mouseleave', function() {
							theTip.hide();
						});
					}
				}
			}

			]
		} ]
	});
};

Fund.getFieldSet6 = function() {

	return Ext.create('Ext.form.FieldSet', {
		title : 'Complience Parameters',
		items : [ {
			// id : 'minUnitHolders',
			xtype : 'numberfield',
			name : 'minUnitHolders',
			fieldLabel : 'Unit Holders(Min)',
			allowBlank : false,
			flex : 1,
			labelWidth : 150,
			padding : '0 10 0 0',
			allowNegative : false,
			blankText : 'Please specify the Minimum Number of Unit Holders',
			// emptyText : 'Minimum Unit Holders',
			msgTarget : 'under',
			listeners : {
				render : function(p) {
					var theElem = p.getEl();
					var theTip = Ext.create('Ext.tip.Tip', {
						html : 'Minimum number of Unitholders',
						margin : '20 0 0 0',
						shadow : false
					});

					p.getEl().on('mouseover', function() {
						theTip.showAt(theElem.getX(), theElem.getY());
					});

					p.getEl().on('mouseleave', function() {
						theTip.hide();
					});
				}
			}
		}, {
			xtype : 'textfield',
			vtype : 'Rate',
			validateOnBlur : true,
			maskRe : /[\d\%.]/,
			name : 'maxInvestPercent',
			fieldLabel : 'Max Invest %',
			labelWidth : 150,
			padding : '0 10 0 0',
			blankText : 'Please specify the Maximum Percentage',
			allowBlank : false,
			msgTarget : 'under',
			listeners : {
				blur : function() {
					var value = Ext.util.Format.number(this.value.replace(/%/g, ''), '000.00');
					this.setRawValue(value + "%");
				},
				render : function(p) {
					var theElem = p.getEl();
					var theTip = Ext.create('Ext.tip.Tip', {
						html : 'Maximun Investment Percentage with a Single Issuer',
						margin : '20 0 0 0',
						shadow : false
					});

					p.getEl().on('mouseover', function() {
						theTip.showAt(theElem.getX(), theElem.getY());
					});

					p.getEl().on('mouseleave', function() {
						theTip.hide();
					});
				}
			}
		}, {
			xtype : 'textfield',
			vtype : 'Rate',
			validateOnBlur : true,
			maskRe : /[\d\%.]/,
			name : 'minLiquidityPercent',
			fieldLabel : 'Min Liquidity %',
			labelWidth : 150,
			allowBlank : false,
			blankText : 'Please specify the Manimum Percentage',
			msgTarget : 'under',
			listeners : {
				blur : function() {
					var value = Ext.util.Format.number(this.value.replace(/%/g, ''), '000.00');
					this.setRawValue(value + "%");
				},
				render : function(p) {
					var theElem = p.getEl();
					var theTip = Ext.create('Ext.tip.Tip', {
						html : 'Minimum Liquidity Percentage',
						margin : '20 0 0 0',
						shadow : false
					});
					p.getEl().on('mouseover', function() {
						theTip.showAt(theElem.getX(), theElem.getY());
					});
					p.getEl().on('mouseleave', function() {
						theTip.hide();
					});
				}
			}
		}, {
			xtype : 'textfield',
			name : 'unitVal',
			value : '10.0000',
			allowBlank : false,
			labelWidth : 150,
			fieldLabel : 'Unit Value',
			fieldStyle : "text-align:right;",
			maskRe : /[\d\,.]/,
			listeners : {
				blur : function() {
					this.setRawValue(Ext.util.Format.number(this.value.replace(/,/g, ''), '0,000.0000'));
				}
			}
		} ]
	});
};

Fund.getCenterPanel = function() {

	var searchBar = Fund.getSearchBar();
	var filedset1 = Fund.getFieldSet1();
	var filedset2 = Fund.getFieldSet2();
	var filedset3 = Fund.getFieldSet3();
	var filedSet4 = Fund.getFieldSet4();
	var filedSet5 = Fund.getFieldSet5();
	var filedSet6 = Fund.getFieldSet6();

	filedSet4.setVisible(false);

	formPanel = Ext.create('Ext.form.FormPanel', {
		title : 'New Fund Creation',
		id : 'NewFundFormPanel',
		autoScroll : true,
		bodyPadding : '20',
		frame : true,
		defaults : {
			labelWidth : 110,
			anchor : '72%'
		},
		fieldDefaults : {
			labelAlign : 'left'
		},
		items : [ searchBar, filedset1, filedset2, filedset3, filedSet4, filedSet5, filedSet6 ],
		buttonAlign : 'center',
		buttons : [ {
			text : 'Save',
			id : 'newFundSaveBtn',
			itemId : 'saveButton',
			handler : function() {
				var form = this.up('form').getForm();
				var custodianContactSum = '';
				var purchasableIns = '';
				var salableIns = '';
				var repoableIns = '';
				var rRepoableIns = '';
				var fdIssuers = '';
				Ext.data.StoreManager.lookup('fundContactStore').each(function(r) {
					custodianContactSum += r.get('name') + ',' + r.get('designation') + ',' + r.get('phone') + ',' + r.get('fax') + ',' + r.get('email') + ';';
				});
				Ext.data.StoreManager.lookup('parchasableInsStore').each(function(r) {
					purchasableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('salableInsStore').each(function(r) {
					salableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('repoableInsStore').each(function(r) {
					repoableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('rRepoableInsStore').each(function(r) {
					rRepoableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('fdIssuerStore').each(function(r) {
					fdIssuers += r.get('id') + ';';
				});

				form.url = 'addNewFund.action';
				if (form.isValid()) {
					formPanel.setLoading('Saving...');
					form.submit({

						params : {
							'custodianContactPersons' : custodianContactSum,
							'purchasableIns' : purchasableIns,
							'salableIns' : salableIns,
							'repoableIns' : repoableIns,
							'rRepoableIns' : rRepoableIns,
							'fdIssuers' : fdIssuers,
							'createdBy' : 'Creater'
						},
						success : function(form, action) {
							Ext.Msg.alert('Success', action.result.name + ' is created.<br> Fund Code: ' + action.result.code);
							Ext.data.StoreManager.lookup('fundContactStore').removeAll();
							Ext.data.StoreManager.lookup('parchasableInsStore').removeAll();
							Ext.data.StoreManager.lookup('salableInsStore').removeAll();
							Ext.data.StoreManager.lookup('repoableInsStore').removeAll();
							Ext.data.StoreManager.lookup('fdIssuerStore').removeAll();
							var saveBtn = Ext.getCmp('newFundSaveBtn');
							saveBtn.enable();
							saveBtn.setVisible(true);
							Ext.getCmp('newFundUpdateBtn').setVisible(false);
							Ext.getCmp('newFundConfirmBtn').setVisible(false);
							Ext.ComponentQuery.query('#newFundStatusLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundCreatedLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundModifiedLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundBalanceLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText('');
							formPanel.setLoading(false);
							form.reset();
						},
						failure : function(form, action) {
							Ext.Msg.alert('Failed', 'There is some error returned from the server.');
							formPanel.setLoading(false);
						}
					});
				} else {
					Ext.Msg.alert("Form Incomplete. Please check!");
				}
			}
		}, {
			text : 'Update',
			id : 'newFundUpdateBtn',
			itemId : 'updateButton',
			hidden : true,
			handler : function() {
				var form = this.up('form').getForm();
				var custodianContactSum = '';
				var purchasableIns = '';
				var salableIns = '';
				var repoableIns = '';
				var rRepoableIns = '';
				var fdIssuers = '';
				Ext.data.StoreManager.lookup('fundContactStore').each(function(r) {
					custodianContactSum += r.get('name') + ',' + r.get('designation') + ',' + r.get('phone') + ',' + r.get('fax') + ',' + r.get('email') + ';';
				});
				Ext.data.StoreManager.lookup('parchasableInsStore').each(function(r) {
					purchasableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('salableInsStore').each(function(r) {
					salableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('repoableInsStore').each(function(r) {
					repoableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('rRepoableInsStore').each(function(r) {
					rRepoableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('fdIssuerStore').each(function(r) {
					fdIssuers += r.get('id') + ';';
				});
				form.url = 'fundUpdate.action';
				if (form.isValid()) {
					formPanel.setLoading('Saving...');
					form.submit({
						params : {
							'custodianContactPersons' : custodianContactSum,
							'purchasableIns' : purchasableIns,
							'salableIns' : salableIns,
							'repoableIns' : repoableIns,
							'rRepoableIns' : rRepoableIns,
							'fdIssuers' : fdIssuers,
							'modifiedBy' : 'ModifiedUser'
						},
						success : function(form, action) {
							Ext.Msg.alert('Success', action.result.name + ' Updated.');
							formPanel.setLoading(false);
							Ext.data.StoreManager.lookup('fundContactStore').removeAll();
							Ext.data.StoreManager.lookup('parchasableInsStore').removeAll();
							Ext.data.StoreManager.lookup('salableInsStore').removeAll();
							Ext.data.StoreManager.lookup('repoableInsStore').removeAll();
							Ext.data.StoreManager.lookup('fdIssuerStore').removeAll();
							var saveBtn = Ext.getCmp('newFundSaveBtn');
							saveBtn.enable();
							saveBtn.setVisible(true);
							Ext.getCmp('newFundUpdateBtn').setVisible(false);
							Ext.getCmp('newFundConfirmBtn').setVisible(false);
							Ext.ComponentQuery.query('#newFundStatusLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundCreatedLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundModifiedLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundBalanceLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText('');
							form.reset();
						},
						failure : function(form, action) {
							Ext.Msg.alert('Failed', 'There is some error returned from the server.');
							formPanel.setLoading(false);
						}
					});
				} else {
					Ext.Msg.alert("Form Incomplete. Please check!");
				}
			}
		}, {
			text : 'Confirm',
			id : 'newFundConfirmBtn',
			itemId : 'confirmButton',
			hidden : true,
			handler : function() {
				var form = this.up('form').getForm();
				var custodianContactSum = '';
				var purchasableIns = '';
				var salableIns = '';
				var repoableIns = '';
				var rRepoableIns = '';
				var fdIssuers = '';
				Ext.data.StoreManager.lookup('fundContactStore').each(function(r) {
					custodianContactSum += r.get('name') + ',' + r.get('designation') + ',' + r.get('phone') + ',' + r.get('fax') + ',' + r.get('email') + ';';
				});
				Ext.data.StoreManager.lookup('parchasableInsStore').each(function(r) {
					purchasableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('salableInsStore').each(function(r) {
					salableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('repoableInsStore').each(function(r) {
					repoableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('rRepoableInsStore').each(function(r) {
					rRepoableIns += r.get('id') + ';';
				});
				Ext.data.StoreManager.lookup('fdIssuerStore').each(function(r) {
					fdIssuers += r.get('id') + ';';
				});
				form.url = 'fundConfirm.action';
				if (form.isValid()) {
					formPanel.setLoading('Saving...');
					form.submit({
						params : {
							'custodianContactPersons' : custodianContactSum,
							'purchasableIns' : purchasableIns,
							'salableIns' : salableIns,
							'repoableIns' : repoableIns,
							'rRepoableIns' : rRepoableIns,
							'fdIssuers' : fdIssuers,
							'confirmedBy' : 'Confirmer'
						},
						success : function(form, action) {
							form.reset();
							Ext.Msg.alert('Success', action.result.name + ' is Confirmed.');
							Ext.data.StoreManager.lookup('fundContactStore').removeAll();
							Ext.data.StoreManager.lookup('parchasableInsStore').removeAll();
							Ext.data.StoreManager.lookup('salableInsStore').removeAll();
							Ext.data.StoreManager.lookup('repoableInsStore').removeAll();
							Ext.data.StoreManager.lookup('fdIssuerStore').removeAll();
							var saveBtn = Ext.getCmp('newFundSaveBtn');
							saveBtn.enable();
							saveBtn.setVisible(true);
							Ext.getCmp('newFundUpdateBtn').setVisible(false);
							Ext.getCmp('newFundConfirmBtn').setVisible(false);
							Ext.ComponentQuery.query('#newFundStatusLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundCreatedLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundModifiedLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundBalanceLbl')[0].setText('');
							Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText('');
							formPanel.setLoading(false);
						},
						failure : function(form, action) {
							Ext.Msg.alert('Failed', 'There is some error returned from the server.');
							formPanel.setLoading(false);
						}
					});
				} else {
					Ext.Msg.alert("Form Incomplete. Please check!");
				}
			}
		}, {
			text : 'Cancel',
			handler : function() {
				App.Core.removeScreen();
			}
		}, {
			text : 'Reset',
			handler : function() {
				formPanel.getForm().reset();
				formPanel.getForm().applyToFields({
					disabled : false
				});
				Ext.data.StoreManager.lookup('fundContactStore').removeAll();
				Ext.data.StoreManager.lookup('parchasableInsStore').removeAll();
				Ext.data.StoreManager.lookup('salableInsStore').removeAll();
				Ext.data.StoreManager.lookup('repoableInsStore').removeAll();
				Ext.data.StoreManager.lookup('rRepoableInsStore').removeAll();
				Ext.data.StoreManager.lookup('fdIssuerStore').removeAll();
				Ext.ComponentQuery.query('#newFundStatusLbl')[0].setText('');
				Ext.ComponentQuery.query('#newFundCreatedLbl')[0].setText('');
				Ext.ComponentQuery.query('#newFundModifiedLbl')[0].setText('');
				Ext.ComponentQuery.query('#newFundBalanceLbl')[0].setText('');
				Ext.ComponentQuery.query('#newFundCodeValidLbl')[0].setText('');
				var saveBtn = Ext.getCmp('newFundSaveBtn');
				saveBtn.enable();
				saveBtn.setVisible(true);
				Ext.getCmp('newFundUpdateBtn').setVisible(false);
				Ext.getCmp('newFundConfirmBtn').setVisible(false);
			}
		} ]
	});
	return formPanel;
};